Imports System.Data.OleDb
Imports System.Data
Partial Class Default2
    Inherits System.Web.UI.Page
    Dim con As OleDbConnection
    Dim cmd As OleDbCommand
    Dim adp As OleDbDataAdapter
    Dim ds As DataSet
    Dim _bo As New Bo
    Dim dtAddToCart As New DataTable
    Dim _UserId As String = "krupa"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\College\Projects\Backup\demo\Database1.mdb")
        'con.Open()
        If (Not IsPostBack()) Then
            bind()
        End If
    End Sub
    Protected Sub dd_RowEditing(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        dd.EditItemIndex = e.Item.ItemIndex
        bind()
    End Sub
    Protected Sub dd_RowCancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        dd.EditItemIndex = -1
        bind()
    End Sub
    Protected Sub dd_RowUpdate(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
        'Dim s As String

        's = CType(e.Item.FindControl("tt"), TextBox).Text
        'cmd = New OleDbCommand("update product set qty=" & s & " where pid='" & e.Item.Cells(0).Text & "'", con)
        'cmd.ExecuteNonQuery()
        'dd.EditItemIndex = -1
        'bind()

        Dim s As String
        s = CType(e.Item.FindControl("tt"), TextBox).Text
        _bo.UpdateQuantityInCart(_UserId, e.Item.Cells(0).Text, s)
        dd.EditItemIndex = -1
        bind()
    End Sub
    Public Sub bind()
        'cmd = New OleDbCommand("select pid,qty from product", con)
        'adp = New OleDbDataAdapter(cmd)
        'ds = New DataSet
        'adp.Fill(ds)
        'dd.DataSource = ds.Tables(0)
        'dd.DataBind()

        Dim dtAddToCart As DataTable
        dtAddToCart = _bo.getcart(_UserId)
        If dtAddToCart.Rows.Count = 0 Then
            MsgBox("No Items In Your Bag")
            Response.Redirect("frmDataList.aspx")
        End If
        dd.DataSource = dtAddToCart
        dd.DataBind()
    End Sub
End Class
